kubernetes-ingress: add extraObjects templating#371
Conversation
Signed-off-by: Artyom Babiy <artyom.babiy@gmail.com>
| ### Extra Objects | ||
|
|
||
| Declare additional arbitrary raw CR manifests to deploy as a part of the helm release. | ||
|
|
There was a problem hiding this comment.
indeed, my bad, added missing table header
| {{/* | ||
| Render extra raw objects that might contain templates | ||
| */}} | ||
| {{- define "kubernetes-ingress.renderExtraObjects" -}} |
There was a problem hiding this comment.
$value is always coerced to a string
(typeIs "string" .value | ternary .value (.value | toYaml)), but the else
branch passes that string straight to merge, which needs a map:
Error: ... executing "kubernetes-ingress.renderExtraObjects" at <$value>:
wrong type for value; expected map[string]interface {}; got string
There was a problem hiding this comment.
maybe something like
{{- define "kubernetes-ingress.renderExtraObjects" -}}
{{- $labels := fromYaml (include "kubernetes-ingress.extraRawLabels" .context) -}}
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
{{- if contains "{{" (toString $value) }}
{{- $value = tpl $value .context }}
{{- end }}
{{- toYaml (merge (fromYaml $value) $labels) }}
{{- end -}}
?
There was a problem hiding this comment.
oh, I decided to complicate the original design that served as an inspiration https://github.com/CloudPirates-io/helm-charts/blob/aff6783b21ce92155849464eb612551d2e8788d5/charts/common/templates/_helpers.tpl#L231-L241 and botched it a bit, but your suggestion seems to be working, so accepted, thanks!
| @@ -0,0 +1,4 @@ | |||
| {{- range .Values.extraObjects }} | |||
| --- | |||
| {{- include "kubernetes-ingress.renderExtraObjects" (dict "value" . "context" $) }} | |||
There was a problem hiding this comment.
{{- include ...}}
will merge with previous line
{{ include ...}}
is more correct here
|
@oktalz hey thank you very much, it should be ready for round 2 |
Allow chart consumers to template arbitrary CRs as part of the helm release.